<?php

namespace app\common\model;

/**
 * [Music  佛乐表]
 * @author [C。]
 * @return html
 */
class Music extends Base
{
    protected $name = 'music';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getlist($map,$from = 0, $size = 5,$field = 'c.cname,n.id,n.title,n.img,n.addtime,n.url,n.itemid,n.states,n.play_num,n.author')
    {
        $order = ['n.id' => 'desc'];
        $join = [
            ['app_musiccate c','n.itemid = c.id'],
        ];

        $result =  $this->field($field)
            ->alias('n')
            ->join($join)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }

    /**
     * 搜索获取列表总数
     * @param array $param
     */
    public function getCount($map) {
        $join = [
            ['app_musiccate c','n.itemid = c.id'],
        ];
        $result =  $this->alias('n')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlists($map,$from = 0, $size = 5,$field = 'id,title,url,img,play_num,states,author')
    {
        $order = ['id' => 'desc'];
        $result =  $this->field($field)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }
    /**
     * 搜索获取寺院列表总数
     * @param array $param
     */
    public function getCounts($map) {
        $result =  $this->where($map)->count();
        return $result;
    }

}